<include file="../Public/_header" />
<div class="so_main">
  <div class="page_tit">博客文章管理</div>
  <!-------- 搜索用户 -------->
  <div id="searchUser_div" <neq name="type" value="searchUser">style="display:none;"</neq>>
  	<div class="page_tit">搜索文章 [ <a href="javascript:void(0);" onclick="searchUser();">隐藏</a> ]</div>
	
	<div class="form2">
	<form method="post" action="{:U('admin/User/doSearchUser')}">
    <dl class="lineD">
      <dt>Email：</dt>
      <dd>
        <input name="email" id="email" type="text" value="{$email}">
        <p>用户进行登录的帐号,多个时使用英文的","分割</p>
      </dd>
    </dl>
	
	<php>if($type != 'searchUser') $uid = '';</php>
    <dl class="lineD">
      <dt>用户ID：</dt>
      <dd>
        <input name="uid" id="uid" type="text" value="{$uid}">
        <p>用户ID,多个时使用英文的","分割</p>
      </dd>
    </dl>
	
    <dl class="lineD">
      <dt>昵称：</dt>
      <dd>
        <input name="uname" id="uname" type="text" value="{$uname}">
        <p>多个时使用英文的","分割</p>
      </dd>
    </dl>
	 
	<dl>
      <dt>用户组：</dt>
      <dd>
      	<a href="javascript:void(0);" onclick="folder('user_group', this);"><php>echo empty($user_group_id) ? '展开' : '收起';</php></a>
        <div id="search_user_group" <php>if(empty($user_group_id)){</php>style="display:none;"<php>}</php>>
			{:W('SelectUserGroup', array('user_group_id'=>$user_group_id))}
		</div>
      </dd>
    </dl>
    
    <dl class="lineD">
      <dt>性别：</dt>
      <dd>
      	<input name="sex" type="radio" value="" <eq name="sex" value="">checked</eq>>全部
        <input name="sex" type="radio" value="1" <eq name="sex" value="1">checked</eq>>男
        <input name="sex" type="radio" value="0" <eq name="sex" value="0">checked</eq>>女
      </dd>
    </dl>
	
	<dl class="lineD">
      <dt>是否激活：</dt>
      <dd>
      	<input name="is_active" type="radio" value="" <eq name="is_active" value="">checked</eq>>全部
        <input name="is_active" type="radio" value="1" <eq name="is_active" value="1">checked</eq>>是
        <input name="is_active" type="radio" value="0" <eq name="is_active" value="0">checked</eq>>否
      </dd>
    </dl>
    <div class="page_btm">
      <input type="submit" class="btn_b" value="确定" />
    </div>
	</form>
  </div>
  </div>
  
  <!-------- 用户列表 -------->
  <div class="Toolbar_inbox">
  	<div class="page right">{$page}</div>
	<a href="javascript:void(0);" class="btn_a" onclick="searchUser();">
		<span class="searchUser_action">
		<neq name="type" value="searchUser">搜索文章
		  <else/>搜索完毕</neq></span>
	</a>
	<a href="javascript:void(0);" class="btn_a" onclick="deleteBlog();"><span>删除文章</span></a>
  </div>
  <div class="list">
  <table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <th style="width:30px;">
		<input type="checkbox" id="checkbox_handle" onclick="checkAll(this)" value="0">
    	<label for="checkbox"></label>
	</th>
    <th class="line_l">ID</th>
    <th class="line_l">用户信息</th>
    <th class="line_l">标题</th>
    <th class="line_l">发布时间</th>
    <th class="line_l">操作</th>
  </tr>
  <volist id="vo" name="bloglist">
	  <tr overstyle='on' id="weibo_{$vo['weibo_id']}">
	    	<td><input type="checkbox" name="checkbox" id="checkbox2" onclick="checkon(this)" value="{$vo.weibo_id}"></td>
	    <td>{$vo.weibo_id}</td>
	    <td>{$vo['uname']}</td>
		<td>
			<a href="{:U('home/Space/index',array('uid'=>$vo['uid']))}">{$vo['title']}</a>
		</td>
	    <td>
			{$vo.ctime|date="Y-m-d H:i",###}
			
		</td>
	    <td>编辑 <a href="javascript:void(0);" onclick="deleteBlog({$vo['weibo_id']});">删除</a></td>
	    
	  </tr>
  </volist>
  </table>
</div>

  <div class="Toolbar_inbox">
	<div class="page right">{$page}</div>
	<a href="javascript:void(0);" class="btn_a" onclick="searchUser();">
		<span class="searchUser_action"><neq name="type" value="searchUser">搜索文章<else/>搜索完毕</neq></span>
	</a>
	<a href="javascript:void(0);" class="btn_a" onclick="deleteBlog();"><span>删除文章</span></a>
  </div>
</div>

<script>
	//鼠标移动表格效果
	$(document).ready(function(){
		$("tr[overstyle='on']").hover(
		  function () {
		    $(this).addClass("bg_hover");
		  },
		  function () {
		    $(this).removeClass("bg_hover");
		  }
		);
	});
	
	function checkon(o){
		if( o.checked == true ){
			$(o).parents('tr').addClass('bg_on') ;
		}else{
			$(o).parents('tr').removeClass('bg_on') ;
		}
	}
	
	function checkAll(o){
		if( o.checked == true ){
			$('input[name="checkbox"]').attr('checked','true');
			$('tr[overstyle="on"]').addClass("bg_on");
		}else{
			$('input[name="checkbox"]').removeAttr('checked');
			$('tr[overstyle="on"]').removeClass("bg_on");
		}
	}

	//获取已选择文章的ID数组
	function getChecked() {
		var weibo_ids = new Array();
		$.each($('table input:checked'), function(i, n){
			weibo_ids.push( $(n).val() );
		});
		return weibo_ids;
	}
	//删除文章
	function deleteBlog(weibo_id) {
		weibo_id = weibo_id ? weibo_id : getChecked();
		weibo_id = weibo_id.toString();
		if(weibo_id == '' || !confirm('删除成功后将无法恢复，确认继续？')) return false;
		
		$.post("{:U('admin/Blog/dodelBlog')}", {weibo_id:weibo_id}, function(res){
			if(res == '1') {
				weibo_id = weibo_id.split(',');
				for(i = 0; i < weibo_id.length; i++) {
					$('#weibo_'+weibo_id[i]).remove();
				}
				ui.success('操作成功');
			}else {
				//ui.error(res);
				ui.error('操作失败');
			}
		});
	}
	
	//搜索用户
	var isSearchHidden = <neq name="type" value="searchUser">1<else/>0</neq>;
	function searchUser() {
		if(isSearchHidden == 1) {
			$("#searchUser_div").slideDown("fast");
			$(".searchUser_action").html("搜索完毕");
			isSearchHidden = 0;
		}else {
			$("#searchUser_div").slideUp("fast");
			$(".searchUser_action").html("搜索用户");
			isSearchHidden = 1;
		}
	}
	
	function folder(type, _this) {
		$('#search_'+type).slideToggle('fast');
		if ($(_this).html() == '展开') {
			$(_this).html('收起');
		}else {
			$(_this).html('展开');
		}
		
	}
</script>

<include file="../Public/_footer" />